// 解析URL中的参数
import moment from "moment/moment";
const origin = 'http://www.xingcha365.com';
export function parseUrl(url: string) {
    const params: any = {}
    try {
        if (url.indexOf('?') > -1) {
            const query = url.split('?')[1]
            const queryArr = query.split('&')
            queryArr.forEach((item) => {
                const key = item.split('=')[0]
                params[key] = decodeURIComponent(item.split('=')[1])
            })
        }
    } catch (e) {
        // console.log(e);
    }
    return params
}
// export function next(data:any){
// data.forEach((item:any) =>{
// if(item.id){

// }
// })
// }
export function weekNumber(date: string) {
    // 计算是本年第几周
    return moment(date).week();
}
export function jumpUcenter(link: string) {
    window.open(origin + '/#/' + link);
}
export function jumpTaoCenter(link: string) {
    window.open(origin + '/taobao/#/' + link);
}
export function digitFormat(number: any,fractionDigits:number=0): string {
    if (typeof number == 'undefined') {
        return '0';
    }
    if (typeof number == "number") {
        return number.toFixed(fractionDigits);
    }
    return String(number).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}